import pandas as pd
from pandas import DataFrame

# 读取数据文件
erp_khxd= pd.read_csv('ERP_KHXD.csv')
erp_fhjl = pd.read_csv('ERP_FHJL.csv')
sys_user = pd.read_csv('sys_user.csv')
erp_khxx = pd.read_csv('ERP_KHXX.csv')
sys_dict_data = pd.read_csv('sys_dict_data.csv')
erp_clxx = pd.read_csv('ERP_CLXX.csv')
erp_fhdxx = pd.read_csv('ERP_FHDXX.csv')
sys_dict_data = pd.read_csv('sys_dict_data.csv')
erp_zdxx = pd.read_csv('ERP_ZDXX.csv')

# 对 erp_khxd 进行处理
erp_khxd['khxd_id'] = erp_khxd['id']
erp_khxd = erp_khxd.drop('id', axis=1)
erp_khxd = erp_khxd.drop('khxx_id', axis=1)
erp_khxd = erp_khxd.drop('zd_id', axis=1)
erp_khxd = erp_khxd.drop('hplx', axis=1)
erp_khxd = erp_khxd.drop('cpgg', axis=1)
erp_khxd = erp_khxd.drop('cppp', axis=1)
erp_khxd = erp_khxd.drop('fhd_id', axis=1)

# 对 erp_zdxx 进行处理
erp_zdxx['zdxx_id'] = erp_zdxx['id']
erp_zdxx = erp_zdxx.drop('id', axis=1)
erp_zdxx = erp_zdxx.drop('khxx_id', axis=1)

# 假设通过 id 字段进行关联
erp_fhjl = erp_fhjl.merge(erp_khxd,on='khxd_id',how='left')
erp_fhjl = erp_fhjl.merge(erp_clxx,on='clxx_id',how='left')
erp_fhjl = erp_fhjl.merge(erp_fhdxx,on='fhdxx_id',how='left')
erp_fhjl = erp_fhjl.merge(erp_khxx,on='khxx_id',how='left')
erp_fhjl = erp_fhjl.merge(erp_zdxx,on='zdxx_id',how='left')
erp_fhjl = erp_fhjl.merge(sys_user,on='user_name',how='left')

#输出汇总表
print(erp_fhjl)
erp_fhjl.to_csv('汇总表.csv',index=False)
erp_fhjl.to_excel('汇总表.xlsx',index=False)